package com.shigen.file.emuns;

/**
 * 是否的枚举
 *
 * @author shigenfu
 * @date 2022/6/13 2:00 上午
 */
public enum YesNoEnum {

  /**
   * 是
   */
  YES(1, "是"),
  /**
   * 否
   */
  NO(0, "否"),
  /**
   * 未知
   */
  UNKNOWN(-1, "未知");

  private Integer code;
  private String desc;

  YesNoEnum(int code, String desc) {
    this.code = code;
    this.desc = desc;
  }

  /**
   * 根据code获得描述信息
   */
  public static String getDesc(Integer code) {
    for (YesNoEnum yesNoEnum : YesNoEnum.values()) {
      if (yesNoEnum.code.equals(code)) {
        return yesNoEnum.desc;
      }
    }
    return "";
  }
}
